package mobi.greenplate.theweb.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import mobi.greenplate.theweb.domain.Community;


@XmlRootElement(name="community-list")
public class CommunityListConverter {

    private final List<Community> entities;

    public CommunityListConverter() {
        this.entities=new ArrayList<Community>();
    }
    
    public CommunityListConverter(List<Community> entities) {
        this.entities = entities;
    }

    @XmlElement
    public List<CommunityConverter> getCommunity(){
        final List<CommunityConverter> list = new ArrayList<CommunityConverter>();
        for (Community community : entities) {
            list.add(new CommunityConverter(community));
        }
        return list;
    }

    @XmlTransient
    public List<Community> getEntities(){
        return Collections.unmodifiableList(this.entities);
    }

}


